
package sg.edu.nus.iss.cats.dataaccess.mysql;

import sg.edu.nus.iss.cats.model.*;
import sg.edu.nus.iss.cats.dataaccess.*;
import java.sql.*;

public class CourseEventObjectHandler implements ObjectHandler {

    public String getTableName () {
        return DBConstants.courseEventsTableName;
    }

    public String getKeyParameterConstraint () {
        return null;
    }

    public void setKeyParameters (PreparedStatement statement, Object obj)
                   throws SQLException, DAOException {
        throw new DAOException ("Method setKeyValues not implemented");
    }

    public Object retrieveObject (ResultSet results)
                    throws SQLException, DAOException {
        CourseEvent obj = new CourseEvent ();
        obj.setCourseId (results.getInt (DBConstants.ce_courseId));
        obj.setCourseEventId (results.getInt (DBConstants.ce_courseEventId));
        obj.setTimeStamp (results.getDate (DBConstants.ce_timestamp));
        obj.setEventType (results.getString (DBConstants.ce_eventType));
        obj.setEventBy (results.getString (DBConstants.ce_eventBy));
        obj.setComment (results.getString (DBConstants.ce_comment));
        return obj;
    }

    public void insertKeys (ResultSet results, Object obj)
                   throws SQLException, DAOException {
    }

    public void updateObject (ResultSet results, Object obj)
                   throws SQLException, DAOException {
        CourseEvent act = (CourseEvent) obj;
        results.updateInt (DBConstants.ce_courseId, act.getCourseId ());
        results.updateInt (DBConstants.ce_courseEventId, act.getCourseEventId ());
        results.updateDate (DBConstants.ce_timestamp, new Date(act.getTimeStamp().getTime()));
        results.updateString (DBConstants.ce_eventType, act.getEventType ());
        results.updateString (DBConstants.ce_eventBy, act.getEventBy ());
        results.updateString (DBConstants.ce_comment, act.getComment ());
    }

    public void completeObjectRetrieve (Object obj) throws DAOException {
    }

    public Object[] getObjectArray (int length) {
        return new CourseEvent [length];
    }

}